--
-- Author: ping.wang
-- Date: 2018-09-19 17:35:53
--
-- CrystalModel
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ModelBase)

function ClassRef:ctor(data)
    self.super.ctor(self, data)
end

function ClassRef:init()
end

------------------------ receive ------------------------


------------------------ request ------------------------
--强化水晶
function ClassRef:reqLevelUpCrystal(isOnEquip,crystalId,equipUid,crystalUid)
    print(isOnEquip,crystalId,equipUid,crystalUid)
    app.session:request("pb_crystal.C2S_UplevelCrystal",{IsOnEquip = isOnEquip, CrystalID = crystalId, EquipUid = equipUid,
        CrystalUid = crystalUid}, function(ret)
        if ret.OK then
            app:sendMsg("CrystalController", "successLevelUpCrystal", ret.IsOnEquip, ret.CrystalID, ret.CrystalUid, ret.EquipUid)
            display.pushToast(L("tips_1070002"))
        else
            --现在显示升级失败 可能要改
            display.pushToast(L("tips_1070003"))
        end
    end)
end

--镶嵌水晶
function ClassRef:reqInsertCrystal(equipUid,crystalUid)
    app.session:request("pb_crystal.C2S_InsertCrystal",{CrystalUid = crystalUid, EquipUid = equipUid}, function(ret)
        if ret.OK then
            app:sendMsg("CrystalController", "successInsertCrystal", ret.EquipUid)
        else
            --现在显示镶嵌失败 可能要改
            display.pushToast(L("rockTips_2"))
        end
    end)
end

--卸下水晶
function ClassRef:reqRemoveCrystal(equipUid,crystalId)
    app.session:request("pb_crystal.C2S_RemoveCrystal",{CrystalID = crystalId, EquipUid = equipUid},
    function(ret)
        if ret.OK then
            app:sendMsg("CrystalController", "successRemoveCrystal",ret.EquipUid)
        else
            --现在显示升级失败 可能要改
            display.pushToast(L("rockTips_3"))
        end
    end)
end
return ClassRef
